﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:l="clr-namespace:Microsoft.VisualStudio.IntellisensePresenter"
    x:Class="Microsoft.VisualStudio.IntellisensePresenter.CompletionSessionView"
    mc:Ignorable="d" MinWidth="400" MinHeight="150" Height="200" Width="600" >
    <UserControl.Resources>
        <DataTemplate x:Key="ItemDataTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"
                                         Value="false">
                                    <Setter Property="UIElement.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Grid.Style>
                    <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FFD7E5F8" CornerRadius="10,0,0,10" OpacityMask="#FFFFFFFF">
                        <Border BorderBrush="{x:Null}" BorderThickness="1,1,1,1" CornerRadius="10,0,0,10" Margin="3,3,0,3">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <LinearGradientBrush.RelativeTransform>
                                        <TransformGroup>
                                            <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1" ScaleY="1"/>
                                            <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                                            <RotateTransform Angle="90" CenterX="0.5" CenterY="0.5"/>
                                            <TranslateTransform X="0" Y="0"/>
                                        </TransformGroup>
                                    </LinearGradientBrush.RelativeTransform>
                                    <GradientStop Color="#FFD7E5F8" Offset="0"/>
                                    <GradientStop Color="#FFA0C0EF" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                    </Border>
                </Grid>
                <Grid Margin="30,0,0,0"  >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Image Source="{Binding Path=IconSource}" />
                    <TextBlock Grid.Column="1" Background="{x:Null}" Padding="0,2.5,0,2.5"  Text="{Binding Path=DisplayText, Mode=Default}" Foreground="#FF045184" Margin="5,0,0,0">
                        <TextBlock.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"
                                         Value="true">
                                        <Setter Property="TextBlock.FontSize" Value="14" />
                                        <Setter Property="TextBlock.FontWeight" Value="Bold" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"
                                         Value="false">
                                        <Setter Property="TextBlock.Opacity" Value="0.8" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </Grid>
            </Grid>
            <DataTemplate.Triggers>
                <EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
            </DataTemplate.Triggers>
        </DataTemplate>
        <Style TargetType="{x:Type ListBoxItem}">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
            </Style.Resources>
        </Style>
        <Style x:Key="IntellisenseListBox" TargetType="{x:Type ListBox}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBox}">
                        <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1" >
                            <ScrollViewer Background="{x:Null}" Padding="{TemplateBinding Padding}" Focusable="false" Margin="0,4,0,4" HorizontalAlignment="Left" Template="{DynamicResource ScrollViewerControlTemplate}">
                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"  />
                            </ScrollViewer>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bd" Value="Transparent"/>
                            </Trigger>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Border Margin="30,0,0,0" Background="#FFD7E5F8" CornerRadius="20">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <ListBox x:Name="listViewCompletions" 
                 Style="{DynamicResource IntellisenseListBox}" 
                 ItemTemplate="{DynamicResource ItemDataTemplate}" 
                 Background="{x:Null}"
                 BorderThickness="0"
                 Margin="-20,0,0,0"
                 Padding="0,0,30,0"
                 ItemsSource="{Binding Session.SelectedCompletionSet.Completions}"               
                 MouseDoubleClick="ListView_MouseDoubleClick" 
                 SelectionChanged="ListView_SelectionChanged" 
                 MouseLeftButtonDown="listViewCompletions_MouseLeftButtonDown">
            </ListBox>
            <StackPanel Grid.Column="1">
                <Label Name="title" FontSize="14" Foreground="#FF306EA0" FontWeight="Bold" Content="{Binding SelectedItem.DisplayText, ElementName=listViewCompletions}"/>
                <TextBlock Text="{Binding SelectedItem.Description, ElementName=listViewCompletions}" Name="description" TextWrapping="Wrap" Background="{x:Null}" Foreground="#FF306EA0" TextTrimming="CharacterEllipsis" FontSize="12" />
            </StackPanel>
            <Thumb Width="20" Height="20" Cursor="SizeNWSE" Opacity="0" DragDelta="OnThumbDragDelta" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
            <Image Height="25" Source="MSDN_logo.png" MouseDown="OnMsdnImageMouseDown" Margin="0,0,20,10" Cursor="Hand" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
        </Grid>
    </Border>
</UserControl>